package test;

import java.util.concurrent.TimeUnit;

public class SubmitThread extends Thread {
    private TaskEngine taskEngine;

    public SubmitThread(TaskEngine taskEngine) {
        this.taskEngine = taskEngine;
    }

    @Override
    public void run() {
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        Command command = new Command(Command.task_create);
        command.setId("1");
        taskEngine.getQueue().offer(command);
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        command = new Command(Command.task_wait);
        command.setId("1");
        taskEngine.getQueue().offer(command);
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        command = new Command(Command.task_wait_cancel);
        command.setId("1");
        taskEngine.getQueue().offer(command);
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        command = new Command(Command.task_engine_wait);
        command.setId("1");
        taskEngine.getQueue().offer(command);
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        command = new Command(Command.task_engine_wait_cancel);
        command.setId("1");
        taskEngine.getQueue().offer(command);
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        command = new Command(Command.task_stop);
        command.setId("1");
        taskEngine.getQueue().offer(command);
        //
        try {
            TimeUnit.SECONDS.sleep(10);
        } catch (Exception e) {
        }
        command = new Command(Command.task_engine_stop);
        command.setId("1");
        taskEngine.getQueue().offer(command);


    }

    public TaskEngine getTaskEngine() {
        return taskEngine;
    }

    public void setTaskEngine(TaskEngine taskEngine) {
        this.taskEngine = taskEngine;
    }
}
